{extend name="default/base/base_seller" /}
{block name="seller_main"}


<div class="alert mt10" style="clear:both;">
    <ul class="mt5">
	<li>{$Think.lang.set_order_amount_range}</li>
        <li>{$Think.lang.set_price_range_recommended}</li>
    </ul>
</div>
<form id="pricerangeform" method="post" target="_self" onsubmit="return checksubmit();">
    <table id="pricerang_table" class="dssc-default-table">
      <thead>
        <tr>
          <th class="tl" style="padding-left:10px;">{$Think.lang.starting_forehead}</th>
          <th class="tl">{$Think.lang.finish_forehead}</th>
          <th class="w120">{$Think.lang.ds_handle}</th>
        </tr>
        <tr>
          <td colspan="20">
            <a id="addrow" href="javascript:void(0);" class="dssc-btn-mini"><span>{$Think.lang.add_line}</span></a>
          </td>
        </tr>
      </thead>
      <tbody>
      {notempty name="pricerange"}
      	{foreach name="pricerange" item="v"}
    	<tr id="row_{$key}">
    		<td class="tl">
              <input type="text" class="txt" value="{$v.s}" name="pricerange[{$key}][s]">
            </td>
    		<td class="tl">
              <input type="text" class="txt" value="{$v.e}" name="pricerange[{$key}][e]">
            </td>
    		<td class="dscs-table-handle">
    			<span>
                  <a class="btn-red" href="JavaScript:void(0);" onclick="delrow({$key});">
                    <i class="iconfont">&#xe725;</i>
                    <p>{$Think.lang.ds_del}</p>
                  </a>
                </span>
    		</td>
    	</tr>
      {/foreach}
      {else /}
        <tr id="row_0">
    		<td class="tl">
              <input type="text" class="txt" value="0" name="pricerange[0][s]">
            </td>
    		<td class="tl">
              <input type="text" class="txt" value="0" name="pricerange[0][e]">
            </td>
    		<td class="dscs-table-handle">
    			<span>
                  <a class="btn-red" href="JavaScript:void(0);" onclick="delrow(0);">
                    <i class="iconfont">&#xe725;</i>
                    <p>{$Think.lang.ds_del}</p>
                  </a>
                </span>
    		</td>
    	</tr>
       {/notempty}
      </tbody>
      	<tfoot>
            <tr class="tfoot">
                <td colspan="4" class="align-center">
                    <div class="bottom">
                        <input type="submit" value="{$Think.lang.ds_submit}" class="submit">
                    </div>
                </td>
            </tr>
        </tfoot>
    </table>
</form>
<script type="text/javascript">
function delrow(i){
    $("#row_"+i).remove();
}
function checksubmit(){
    var result = true;
    $("#pricerang_table").find("[name^='pricerange']").each(function(){
        if(!$(this).val()){
            result = false;
        }
    });
    if(!result){
        layer.alert('{$Think.lang.please_complete_price_range}');
    }
    return result;
}
$(function(){
    var i = {:count($pricerange)};
    i += 1;
    var html = '';
    /*新增一行*/
    $('#addrow').click(function(){
        html = '<tr id="row_'+i+'">';
        html += '<td class="tl"><input type="text" name="pricerange['+i+'][s]" value=""/></td>';
        html += '<td class="tl"><input type="text" name="pricerange['+i+'][e]" value=""/></td>';
        html += '<td class="dscs-table-handle"><span><a class="btn-red" href="JavaScript:void(0);" onclick="delrow('+i+');"><i class="iconfont">&#xe725;</i><p>{$Think.lang.ds_del}</p></a></span></td>';

        $('#pricerang_table').find('tbody').append(html);
        i += 1;
    });
})
</script>


{/block}
